class InitLoad{
    //cover 页面初始化背景层
    //load 页面加载遮罩层小猫
    //endbox 直播结束层
    //video-container 直播层

    //加载中
    static videoLoad(){
        $('#video-container').addClass('mui-hidden');
        $('#load').removeClass('mui-hidden');
        $('#cover').removeClass('mui-hidden');
    }

	//直播结束
    static videoUnPlay(){
        $('#load').addClass('mui-hidden');
        $('.endbox').removeClass('mui-hidden');
        $('#cover').removeClass('mui-hidden');
    }

    //直播中
	static videoPlay(){
		$('#cover').addClass('mui-hidden');
		$('.endbox').addClass('mui-hidden');
		$('#load').addClass('mui-hidden');
		$('#video-container').removeClass('mui-hidden');
	}
}

class Video{
    static play(){
        InitLoad.videoPlay();
        /**
         * 视频类型播放优先级
         * mobile ：m3u8>mp4
         * PC ：RTMP>flv>m3u8>mp4
         */
        var options = {
            "rtmp": playUrl.rtmp,
            "flv": playUrl.flv,
            "m3u8": playUrl.hls,
            "autoplay" : false,
            "poster" : {"style": "stretch", "src": onlineRow.room_img},
            "width" :  '100%',
            "height" : '100%',
            "controls":"none",
            "wording": {
                2: '',
                2032: '请求视频失败，请检查网络',
                2048: '请求m3u8文件失败，可能是网络错误或者跨域问题'
            },
            listener: function (msg) {
                var type = msg.type;
                if(type == 'error'){
                    InitLoad.videoUnPlay();
                }
            }
        };
        window.tcplayer = new TcPlayer('video-container', options);
        window.tcplayer.play();
    }
}